package com.zb.spring5.aop;

import org.springframework.aop.framework.ProxyFactory;

/**
 * 把通知和目标对象加入代理中
 */
public class AgentAOPDemo {

    public static void main(String[] args) {
        Agent agent = new Agent();

        ProxyFactory pf = new ProxyFactory();
        pf.addAdvice(new AgentDecorator());
        pf.setTarget(agent);

        Agent proxy = (Agent) pf.getProxy();
        agent.speak("bobo");
        System.out.println();
        proxy.speak("bobo");
    }
}
